﻿using System;
using MathTools;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestProject1 {
    [TestClass]
    public class UnitTest1 {
        [TestMethod]
        public void TestMethod1() {
            Sign s1 = 2.5d;
            Sign s2 = 3.8d;
            var s3 = s1 * s2;
            Console.WriteLine(s3);
        }
        [TestMethod]
        public void MyTestMethod() {
            Sign s1,s2,s3,s4,s5;
            s1 = 10; s2 = 218; s3 = 3.5; s4 = 7.7d; s5 = 29;
            //var s = s1 + s2 * s3 + s4 / s5;
            s4 = s4 / s5;
            s3 = s3 + s4;
            s2 = s2 * s3;
            s1 = s1 + s2;

            s3 = s3 << 1; s5 = s5 >> 1;
            Console.WriteLine(s1);
            Console.WriteLine(10+218*(3.5+7.7/29));
        }
        [TestMethod]
        public void M2() {
            Sign s = "25*81+6+17/2";
            Console.WriteLine(s);
        }
        [TestMethod]
        public void M3() {
            Sign s = "25*81+6+17/2+2*2+1*5+8/20+5-8";
            double s2 = 25*81+6+17/2+2*2+1*5+8/20+5-8;
            Console.WriteLine(s);
            Console.WriteLine(s2);
        }
        [TestMethod]
        public void M5() {
            Sign s = "25 * (81 + 6 + 17 / 2 + 2) * 2 + 1 * 5 + 8 / 20 + 5 - 8";
            double s2 = 25 * (81 + 6 + 17d / 2 + 2) * 2 + 1 * 5 + 8d / 20 + 5 - 8;
            Console.WriteLine(s);
            Console.WriteLine(s2);
        }
        [TestMethod]
        public void M6() {
            Sign s = "25 * (81 + 6 + 17 / 2) + 2 * (2 + 1 * (5 + 8) / 20) + 5 - 8";
            double s2 = 25 * (81 + 6 + 17d / 2) + 2 * (2 + 1 * (5 + 8d) / 20) + 5 - 8;
            Console.WriteLine(s);
            Console.WriteLine(s2);
        }

        [TestMethod]
        public void M4() {
            Sign s = "10 + 218 * (3.5 + 7.7 / 29)";
            Console.WriteLine(s);
            Console.WriteLine(10 + 218 * (3.5 + 7.7 / 29));
        }
        [TestMethod]
        public void M7() {
            Sign s = "2^2*(3.5+58)&3";
            Console.WriteLine(s);
            Console.WriteLine(Math.Pow(2,2)*Math.Log(3.5+58,3));
        }
        [TestMethod]
        public void M8() {
            Sign s = "25 * (81 + 6 + 17 / 2) + 2 * (2 + 1 * (5 + 8) / 20) + 5 - 8";
            double s2 = 25 * (81 + 6 + 17d / 2) + 2 * (2 + 1 * (5 + 8d) / 20) + 5 - 8;
            Console.WriteLine(s);
            Console.WriteLine(s);
            Console.WriteLine("{0}  :  {1}",s.ToString(),(double)s);
            Console.WriteLine(s2);
            Console.WriteLine("------------------------------------");
            Console.WriteLine(s.ToString());
            Console.WriteLine("------------------------------------");
        }

        [TestMethod]
        public void M9() {
            Sign s = "10 + 218 * (3.5 + 7.7 / 29)";
            s[2].Name = "x";
            s.Setting(-20,31.8,10,"x");
            var rs=s.Parse("x");
            Console.WriteLine(s);
            Console.WriteLine("------------------------------------------");
            foreach (var item in rs) {
                Console.WriteLine("{0}  {1}",item[0],item[1]);
            }
            Console.WriteLine("------------------------------------------");
            Console.WriteLine(10 + 218 * (3.5 + 7.7 / 29));
        }
        [TestMethod]
        public void M10() {
            Sign s = "10 + 218 * (3.5 + 7.7 / 29)";
            var x = "x";
            s[2].Name = x;
            s.Setting(-20,31.8,10,x);
            var rs = s.Parse(x);
            Console.WriteLine(s);
            Console.WriteLine(s.ToString(x));
            Console.WriteLine("------------------------------------------");
            foreach (var item in rs) {
                Console.WriteLine("{0}  {1}",item[0],item[1]);
            }
            Console.WriteLine("------------------------------------------");
            Console.WriteLine(10 + 218 * (3.5 + 7.7 / 29));
        }
        [TestMethod]
        public void M11() {
            Sign s = "10 + 218 * (3.5 + 7.7 / 29)";
            var x = "x";
            var x2 = "x2";
            s[2].Name = x;
            s[4].Name = x2;
            s.Setting(-20,31.8,10,x);
            s.Setting(-8,71.8,35,x2);
            var rs = s.Parse(x);
            var rs2 = s.Parse(x2);
            Console.WriteLine(s);
            Console.WriteLine(s.ToString(x));
            Console.WriteLine("------------------------------------------");
            foreach (var item in rs) {
                Console.WriteLine("{0}  {1}",item[0],item[1]);
            }
            Console.WriteLine("------------------------------------------");
            Console.WriteLine(s.ToString(x2));
            Console.WriteLine("------------------------------------------");
            foreach (var item in rs2) {
                Console.WriteLine("{0}  {1}",item[0],item[1]);
            }
            Console.WriteLine("------------------------------------------");
            Console.WriteLine(s);
            Console.WriteLine(10 + 218 * (3.5 + 7.7 / 29));
        }
    }
}
